<?php
/* @var $this ProductController */

$this->breadcrumbs=array(
Yii::t('default', 'Product') => array('index', 'catID' => md5($product->categoryID)),
Yii::t('default', 'Product Detail')
);
?>
<div class="clearfix title_bar">
  <span class="sub_title"> Chi tiết sản phẩm</span>
</div>
<!-- **Primary Section** -->
<section id="primary" class="content-full-width"> <!-- **Product** -->
<div class="product">

    <h2>
    <?php echo $product->name?>
    </h2>

  <div class="images">
    <a class="woocommerce-main-image" title=""> <?php
    $image = Product::model()->getProductFile($product->id, 520, 400);
    ?> <img style="width: 400px; height: 360px;"
      src="<?php echo Yii::app()->baseUrl ?>/upload/product/thumbs_520x400/<?php echo $image?>"
      class="thumbs04" alt="" title=""> </a>
      <?php
      $product_files = Product::model()->getProductFiles($product->id, $image);
      if (!empty($product_files)) {
        ?>
    <div class="thumbnails">
      <div id="product-thumbnails">
      <?php foreach ($product_files as $product_file) {?>
        <a title="" class="product_thumbnail"> <img class="thumbs02"
          src="<?php echo Yii::app()->baseUrl ?>/upload/product/thumbs_160x125/<?php echo $product_file['save']?>"
          alt="" title=""> </a>
          <?php }?>
      </div>

      <div class="product-arrows">
        <a href="#" title="" class="prev" id="product-thumbnails-prev">
        </a> <a href="#" title="" class="next"
          id="product-thumbnails-next"> </a>
      </div>
    </div>
    <?php }?>
  </div>
  <div class="summary mar_top3">
    <div class="description">
    <?php echo $product->description?>
      <p>
        <strong> <?php echo Yii::t('default', 'Category')?> </strong> :
        <?php echo $category?>
      </p>
      <p>
        <strong> Giá </strong> : Liên hệ 0909000900 để được tư vấn
      </p>
    </div>
  </div>

  <?php if (!empty($related_products)) {?>
  
  <!-- div class="border-title">
    <h2>
    <?php echo Yii::t('default', 'Sản phẩm cùng loại')?>
    </h2>
  </div-->
  
   <div class="border-title">
    <h2>
   
    </h2>
  </div>
  
  <div class="clearfix title_bar mar_top3">
  <span class="sub_title"> Sản phẩm cùng loại</span>
  </div>

  <!-- **Product Carousel Wrapper** -->
  <div class="product-carousel-wrapper gallery">
    <ul class="product-carousel products">
    <?php foreach ($related_products as $related_product) {
      $img = Product::model()->getProductFile($related_product['id'], 250, 240);
      ?>
      <li>
        <div class="product-thumb">
          <a
            href="<?php echo Yii::app()->baseUrl ?>/product/detail/id/<?php echo  md5($related_product['id']) ?>"
            title=""> <?php
            $image = Product::model()->getProductFile($related_product['id'], 250, 240);
            echo CHtml::image(Yii::app()->baseUrl . "/upload/product/thumbs_250x240/$img", "image", array('class'=>'thumbs01'));
            ?> </a>
        </div> <a
        href="<?php echo Yii::app()->baseUrl ?>/product/detail/id/<?php echo  md5($related_product['id']) ?>"
        title=""><?php echo $related_product['name']?> </a>

        <p>
          <a
            style="color: red; font-weight: normal; font-style: italic;"
            href="<?php echo Yii::app()->baseUrl ?>/product/detail/id/<?php echo  md5($related_product['id']) ?>"
            title=""> <img alt=""
            src="<?php echo Yii::app()->baseUrl ?>/images/xemthem.jpg"
            title="Xem thêm" align="right"> </a>
        </p>
        <div class="details">
          <span class="price"> LH: 0938.878.538 </span>
        </div>
      </li>

      <?php }?>
    </ul>
    <div class="carousel-arrows">
      <a href="#" title="" class="product-prev-arrow"> <span
        class="icon-chevron-left"> </span> </a> <a href="#" title=""
        class="product-next-arrow"> <span class="icon-chevron-right"> </span>
      </a>
    </div>
  </div>
  <!-- **Product Carousel Wrapper - End** -->
  <?php }?>

</div>
</section>



<!-- **Primary Section** -->

<script type="text/javascript">
$(function () {
  $(".product_thumbnail").click(function() {
    var thumbnail = $(this).children('img').attr('src');
    var file1 = thumbnail.substr(thumbnail.lastIndexOf("/") + 1);
    var image = $(".woocommerce-main-image img").attr('src');
    var file2 = image.substr(image.lastIndexOf("/") + 1);
    $(".woocommerce-main-image img").attr('src' , baseUrl + '/upload/product/thumbs_520x400/' + file1);
    $(this).children('img').attr('src', baseUrl + '/upload/product/thumbs_160x125/' + file2);
  });
});
</script>
